/*
var isString = function( obj ){
    return Object.prototype.toString.call( obj ) === '[object String]';
};
var isArray = function( obj ){
    return Object.prototype.toString.call( obj ) === '[object Array]';
};
var isNumber = function( obj ){
    return Object.prototype.toString.call( obj ) === '[object Number]';
};*/
/*var isType = function (type) {
    return function (obj) {
        return Object.prototype.toString.call(obj) === '[object ' + type + ']';

    }
};*/
/*利用回调函数提取公共部分*/
/*
var isType = function (type) {
    return function (obj) {
        return Object.prototype.toString.call(obj) === '[object ' + type + ']';
    }
};

var isString = isType('String');
var isArray = isType('Array');
var isNumber = isType('Number');
console.log(isArray([1, 2, 3]));
console.log(isNumber(122))
*/


/*var Type = {};
for ( var i = 0, type; type = [ 'String', 'Array', 'Number' ][ i++ ]; ){
    (function( type ){
        Type[ 'is' + type ] = function( obj ){
            return Object.prototype.toString.call( obj ) === '[object '+ type +']';
        }
    })( type )
};*/
/*x循环创建函数*/
var Type={};
for(var i=0,type;type=['String','Array','Number'][i++];){
    (function(type){
        Type['is'+type]=function(obj){
            return Object.prototype.toString.call(obj)==='[object '+type +']'
        }
    })(type)
}
Type.isArray( [] ); // 输出：true
Type.isString( "str" ); // 输出：true
console.log(Type)